<template>
  <div class="detail">
    <banner :sightName="sightName" :bannerImg="bannerImg" :gallaryImgs="gallaryImgs"></banner>
    <Header :sightName="sightName"></Header>
    <div class="content">
      <List :list="categoryList"></List>
    </div>
  </div>
</template>
<script>
import Header from "./components/Header";
import Banner from "./components/Banner";
import List from "./components/List";
import axios from "axios"

export default {
  name: "Detail",
  components: {
    Banner,
    Header,
    List
  },
  data() {
    return {
      sightName: '',
      bannerImg: '',
      gallaryImgs: [],
      categoryList: [],
      lastId: ''
    };
  },
  methods: {
    async getDetailInfo () {
      let result = await axios.get('/api/detail.json?', {
        params: {
          id: this.$route.params.id
        }
      })
      result = result.data
      if(result.ret && result.data) {
        let data = result.data
        this.sightName = data.sightName
        this.bannerImg = data.bannerImg
        this.gallaryImgs = data.gallaryImgs
        this.categoryList = data.categoryList
      }
    },

  },
  mounted () {
    this.getDetailInfo()
    this.lastId = this.$route.params.id
  },
  activated () {
    if(this.lastId !== this.$route.params.id) {
      this.getDetailInfo()
      this.lastId = this.$route.params.id
    }
  }
};
</script>
<style lang="scss" scoped>
.content {
  height: 12rem;
}
</style>


